Skip to main content

Concatenate Clips

Description

The concatenate_clips function sends a request to concatenate video clips from a specific device within a given time range and uploads the concatenated video to a specified URL.

Function Signature:

def concatenate_clips(ws_config: WebServiceConfig, device_id: int, device_name: str, start_epoch: int, end_epoch: int, upload_url: str, postback_url: str) -> WebServiceResult:

Parameters

  • ws_config (WebServiceConfig): The configuration object for the web service.
  • device_id (int): The ID of the device where the video clips were recorded.
  • device_name (str): The name of the device.
  • start_epoch (int): The starting epoch time (in seconds) for the time range.
  • end_epoch (int): The ending epoch time (in seconds) for the time range.
  • upload_url (str): The URL to upload the concatenated video clip to.
  • postback_url (str): The URL to send the postback request to after the video clip has been uploaded.

Returns

  • WebServiceResult: The result of the web service request, which includes:
    • http_response_code: The HTTP response code from the server (e.g., 200 for success).
    • http_response_string: The response body from the server, which may contain success information or errors.
    • json_data: The parsed JSON response data, if available.

Example Usage

ws_config = WebServiceConfig(base_url="https://api.actionstreamer.com")
device_id = 12345
device_name = "DeviceABC"
start_epoch = 1609459200 # Start of January 1, 2021
end_epoch = 1609545600 # End of January 1, 2021
upload_url = "https://example.com/upload"
postback_url = "https://example.com/postback"

result = concatenate_clips(ws_config, device_id, device_name, start_epoch, end_epoch, upload_url, postback_url)
print(result.http_response_code, result.http_response_string)

Behavior

  • Sends a POST request to v1/videoclip/concatenate with the specified device ID, device name, time range, and URLs for upload and postback.
  • Returns a WebServiceResult containing the response code, message, and parsed JSON data.

Error Handling

  • General Exception: If any exception occurs during the request or processing, the function logs the error, sets the response code to -1, and includes a message in the response string indicating the failure.